﻿using System;
using System.Collections.Generic;

using E.BLL;
using E.Model;
using E.Enum;
using E.Web.UI.Page;

using X.Common;
using X.Pager;
using X.Pager.List;

namespace E.Web.Teacher.internals.publics.course
{
    public partial class List : TeacherBasePage
    {
        public Dictionary<int, string> projectList;
        public IList<ShortCourseModel> courseList = new List<ShortCourseModel>();
        public string act, name;
        public int pid;

        protected override void ShowPage()
        {
            CourseBLL bll = new CourseBLL();
            projectList = bll.GetInternalPublicProjectList();

            act = XRequest.GetString("act");
            pid = XRequest.GetInt("ProjectSlt", -1);
            name = XRequest.GetString("NameTxt");

            if (ispost || act == "s")
            {
                SearchCourseModel searchModel = new SearchCourseModel();
                searchModel.Name = name;
                searchModel.CnPID = pid;
                searchModel.IsPublic = 0;

                CourseListModel listModel = new CourseListModel();

                CheckPageIndexValue(XRequest.GetInt("s", 1) - 1, XRequest.GetInt("g", 0), XRequest.GetInt("z", customerPageSize));

                listModel = bll.GetInternalPublicCourseListByCondition(searchModel, customerPageSize, pageIndex);
                if (listModel.TotalCount > 0)
                {
                    count = listModel.TotalCount;
                    courseList = listModel.List;
                    PagerBase pager = new ListPager(count, pageIndex, currentPgGroup, customerPageSize, defaultPagesInGroup);

                    Dictionary<string, string> parms = new Dictionary<string, string>();
                    parms.Add("act", act);
                    parms.Add("ProjectSlt", pid.ToString());
                    mypager = pager.DrawPager("selfpager", parms);
                }
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {

        }
    }
}
